﻿@page
@using Acme.BookStore.Localization;
@using Acme.BookStore.Permissions;
@using Acme.BookStore.Web.Pages.Books;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Localization;
@model Acme.BookStore.Web.Pages.Books.IndexModel
@inject IStringLocalizer<BookStoreResource> L
@inject IAuthorizationService AuthorizationService
@section scripts
{
    <abp-script src="/Pages/Books/Index.js" />
}
<abp-card>
    <abp-card-header>
        <abp-row>
            <abp-column size-md="_1">
                <abp-card-title>@L["Books"]</abp-card-title>
            </abp-column>
            <abp-column size-md="_1">
                <abp-input id="NameQueryInput" asp-for="@Model.NameQuery" floating-label />
            </abp-column>
            <abp-column size-md="_1">
                <abp-input id="AuthorNameQueryInput" asp-for="@Model.AuthorNameQuery" floating-label />
            </abp-column>
            <abp-column size-md="_1">
                <abp-button id="SearchButton"
                            text="查询"
                            icon="search"
                            button-type="Primary">
                </abp-button>
            </abp-column>
            <abp-column size-md="_6" class="text-center">
                @if (await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Create))
                {
                    <abp-button id="NewBookButton"
                        text="@L["NewBook"].Value"
                        icon="plus"
                        button-type="Primary">
                    </abp-button>
                }

                @if (await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Import))
                {
                    <abp-button id="ImportTemplateButton"
                                text="导入模板"
                                icon="plus"
                                button-type="Primary">
                    </abp-button>
                    <abp-button id="ImportBookButton"
                                text="导入"
                                icon="plus"
                                button-type="Primary">
                    </abp-button>
                }
                @if (await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Export))
                {
                    <abp-button id="ExportBookButton"
                                text="导出"
                                icon="plus"
                                button-type="Primary">
                    </abp-button>
                }
            </abp-column>
        </abp-row>
    </abp-card-header>
    <abp-card-body>
        <abp-table striped-rows="true" id="BooksTable"></abp-table>
    </abp-card-body>
</abp-card>
